<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class M_payment_mode_value Extends MY_Model
{

	public function __construct()
	{
		parent::__construct();
	}

	// Retrieve
	public function get_payment_plan_values($level_id = FALSE, $payment_mode_id = FALSE){
		if($level_id == FALSE AND $payment_mode_id == FALSE){
			$q =  $this->db->get('payment_mode_values');
			return $q->num_rows() >= 1 ? $q->result_array() : FALSE;
		}else{
			$q = $this->db->select('payment_plan_tuit,payment_plan_matr')
					  ->where('level_id',$level_id)
					  ->where('ay_id',$this->c_sy->id)
					  ->where('payment_mode_id',$payment_mode_id)
					  ->get('payment_mode_values');
			return $q->num_rows() >= 1 ? TRUE : FALSE; 
		}
	}

	public function get_payment_plan_tuit($level_id = FALSE, $payment_mode_id = FALSE){
		if($level_id == FALSE AND $payment_mode_id == FALSE){
			return FALSE;
		}else{
			$q = $this->db->select('payment_plan_tuit')
					  ->where('level_id',$level_id)
					  ->where('payment_mode_id',$payment_mode_id)
					  ->get('payment_mode_values');
			return $q->num_rows() >= 1 ? $q->row() : FALSE; 
		}
	}
	public function get_payment_plan_matr($level_id = FALSE, $payment_mode_id = FALSE, $sy_id = FALSE){
		if($level_id == FALSE AND $payment_mode_id == FALSE){
			return FALSE;
		}else{
			$q = $this->db->select('payment_plan_matr')
					  ->where('level_id',$level_id)
					  ->where('payment_mode_id',$payment_mode_id)
					  ->where('ay_id',$sy_id)
					  ->get('payment_mode_values');
			return $q->num_rows() >= 1 ? $q->row() : FALSE; 
		}
	}
	public function get_student_payment_schedule($e_id){
		$check = 'SELECT *
				  		FROM student_payment_schedules
				  		WHERE sps_e_id = ?
				  		ORDER BY sps_id ASC';
					
		$q_check = $this->db->query($check,array($e_id));
		if($q_check->num_rows() >=1)
		{
			return $q_check->result();
		}else{
			return FALSE;
		}
	}
	public function get_student_enrollment_fees($e_id){
		$check = 'SELECT *
				  		FROM student_enrollment_fees
				  		WHERE sef_enrollment_id = ?';
					
		$q_check = $this->db->query($check,array($e_id));
		if($q_check->num_rows() >=1)
		{
			return $q_check->result();
		}else{
			return FALSE;
		}
	}
}